import java.util.Scanner;

public class 辗转相除求最大公约数 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("请输入两个数：");
        int a = input.nextInt();
        int b = input.nextInt();
        int c = a % b;
        System.out.print( a + "和" + b + "的最大公约数是：");
        while (c > 0){
            a = b;
            b = c;
            c = a % b;
        }
        System.out.println(b);
    }
}
